﻿

<div >
    <label for="type"></label>
    @Html.Label("", "项目: ") @Html.DropDownList("projectfilter", new[] { new SelectListItem() { Text = "-请选择-", Value = "" } }, new { style = "width:145px;", @class = "projectfilter" })
    @Html.Label("", "成员: ")@Html.DropDownList("memberfilter", new[] { new SelectListItem() { Text = "-请选择-", Value = "" } }, new { style = "width:145px;", @class = "memberfilter" })
</div>
<script type="text/javascript">

    function initialProjectMemberfilter() {
        $(".projectfilter").change(function () {
            var projectid = $(this).val();
            var $member = $(this).parent().find(".memberfilter");

            $member.children().remove();
            $member.append("<option value=''>-请选择-</option>");

            $.ajax({
                url: "/task/memberfilter",
                type: 'GET',
                dataType: 'json',
                contentType: 'application/json; charset=utf-8',
                data: { projectid: projectid },
                success: function (result) {
                    if (result) {

                        for (var i = 0; i < result.length; i++) {

                            $member.append("<option value='" + result[i].val + "'>" + result[i].text + "</option>");
                        }

                    }
                }
            });

        });
        $(".projectfilter").children().remove();
        $(".projectfilter").append("<option value=''>-请选择-</option>");
        $.ajax({
            url: "/task/projectfilter",
            type: 'GET',
            dataType: 'json',
            contentType: 'application/json; charset=utf-8',
            success: function (result) {
                if (result) {
                    for (var i = 0; i < result.length; i++) {
                        var val = result[i].value;
                        var text = result[i].text;
                        $(".projectfilter").append("<option value='" + val + "'>" + text + "</option>");
                    }

                }
            }
        });
    }
</script>
